﻿using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace GameName1
{
    class SpaceShipStateRecovering : SpaceShipState
    {
        private double _start;
        private double _lastFrame;
        public SpaceShipStateRecovering(GameTime gameTime)
        {
            _start = gameTime.TotalGameTime.TotalMilliseconds;
        }

        public override void Update(GameTime gameTime, SpaceShip spaceShip)
        {
            spaceShip.GetInput();
            if (gameTime.TotalGameTime.TotalMilliseconds > _lastFrame + 100)
            {
                spaceShip.Frame++;
                _lastFrame = gameTime.TotalGameTime.TotalMilliseconds;
            }
            if (gameTime.TotalGameTime.TotalMilliseconds > _start + 2000)
            {
                spaceShip.Frame = 0;
                spaceShip.SpaceShipState = new SpaceShipStateNormal();
            }
        }

        public override void Draw(SpriteBatch spriteBatch, SpaceShip spaceShip)
        {
            spriteBatch.Draw(spaceShip.Sprite, spaceShip.GetDestinationRectangle(), spaceShip.GetSourceRectangle(), Color.Red);
        }

        public override void HandleHit(IHittable other, GameTime colissionTime, SpaceShip spaceShip)
        {
            //nope
        }
    }
}
